package com.example.monitoringsystem.controller;

import com.example.monitoringsystem.bean.Prescription;
import com.example.monitoringsystem.bean.User;
import com.example.monitoringsystem.service.PrescriptionService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class PrescriptionController {
    @Autowired
    private PrescriptionService prescriptionService;

    //根据病人id显示处方
    @GetMapping("patient/prescription")
    @ResponseBody
    public Map showPrescription(int patientId){
        User user = (User) SecurityUtils.getSubject().getPrincipal();
        Map prescriptions = prescriptionService.showPrescription(user.getId(), patientId);
        return prescriptions;
    }

}
